Daily builds / downloads available
I've set up a cron job now, so all the bindings and binaries are built daily, you can download them from here.
http://devel.akbkhome.com/gtkjs/gtkjs_snapshot.tar.bz2This
includes gtkjs, mjs and jsfastcgi, In theory it would not take too much
to build this on Windows... - Send me the fixes if you attempt
it...
Just download, unzip and try out
./gtkjs test/filetree.ds
etc.
the
gtkdjs Documentation is updated daily to match
And I still need a better name for the project;)
Closure and scoping fixes.
After seeing a post on the
DMDScript newsgroup concerning closures and scoping issues, I spent quite a while looking at the issue.
The
basic problem, was that the original DMDscript code was designed to
create a cache of function definitions, and re-use them whenever they
where refered to. Along with this, they had no concept of
creationScope. so variables in the creating scope where not available.
Fixing this involved quite a few changes to the compiler and runtime.
Basically creating new Function instances when they are found, rather
than only once at compile time. Along with storing the scope inside the
Function instance. so when they are called they understand the correct
scope. Anyway standard Javascript scoping, and closures all work as
expected.
Undefined Warnings improved
I mentioned in
my last post that I added Warnings when undefined variables where
accessed, I've modified this slightly as undefined is a valid type in
Javascript, so unassigned arguments to a function call are flagged as
undefined, but accessing them should not issue a warning. So only when
the scope.Get(variablename) calls return null, rather than a
Value.vtype[V_UNDEFINED] flag this warning now.
LibSoup extension
LibSoup
provides HTTP support, at present, basic sync requests work, the
code is there for async calls, but I've not tested it yet. test code is
in tests/Soup/.
This little bit of code get's my web site, and shows headers, then extracts all the href from all the <a> tags.
var sess = new Soup.SessionSync();
var msg = new Soup.Message("GET", "http://www.akbkhome.com/");
status = sess.sendMessage(msg);
println("Status is " + status);
println("ResponseHeaders is " + msg.responseHeaders.toSource());
var imp = new Dom.Implementation;
var doc = imp.createHtmlDocFromMemory(msg.response);
var a_s = doc.getElementsByTagName("a");
for(var i =0; i < a_s.length; i++) {
println("got href: " + a_s.item(i).getAttribute("href"));
}
XML2 limited support
To
enable parsing of html documents for Gdome, I've added limited support
for XML2, it's mostly used by the Gdome method:
Dom.Implementation.prototype.createHtmlDocFromMemory( String htmltext )The
Generator code is currently tied into the libxml header files on my
system.. this needs fixing so it uses the gtkwrap download script. (but
the code is a nice example of how to automatically create bindings
based on .h files..)
Gtk.SourceView support
In
preperation for testing text editing (and eventually self-editing /
morphing of applications), I've bound the GtkSourceView widget. Unlike
the standard Leds editor which uses scintilla, I thought I'd try and
see if using GtkSourceView would prove more robust. - The bindings had
already been done for GtkD, so there was not much to change to the
APILookupSourceView.txt code. I only used the full name "sourceview"
rather than "gsv"
Handling of missing functions and Libraries improved
When
I was testing GtkToolbar on one of my machines which had an old Gtk
library, I discovered a segfault when it called a newer function that
did not exist in the old library. To fix this, the Loader.d file now
binds a simple function that throws and exception to any method it can
not bind. So you can catch in javascript any call to unsupported
methods in a library.
Phobos Path module added
all
the methods from
std.path are
now exported to javascript, and in the manual. This enables a few
usefull functions like
var file = "/etc/passwd"
println("Directory = " + Path.getDirName(file));
println("Filename = " + Path.getBaseName(file));
println("combined filename = " + Path.join("etc","passwd"));
Regex Fixes
In testing extjs parsing, I came across two bugs in D's regex implementation, that prevented it's loading.
- forgetful
parsing (?:abc|cde|xyz) - the fix for this was trivial and is in D's
bugtracker, and there is a modified regex file in the dmdscript
distribution.
- the use of special chars in character range
matching after the '-'. eg. [\w-\*] and [\w-\.] which should be
interpreted as [\w\*-] and [\w\.-]. These currently parse correctly
however I've not got round to fixing the implementation properly so
they are pretty broken at present. (basically matching everything from
\w onwards...) - the bugs in D's bugtraker, but the fix is not... I may
get back to this...
Simplified exporting of Structures
One
of the missing pieces for the Gtk Bindings, that I came accross with
jLeds, was the event structures had not been bound. Since they are very
simple structs, and you only need to get access to their properties, I
developed a new action for the wrap file "structDump" which
autogenerates the class file, forces the full Struct definition to be
written and writes getter methods for all the exportable properties.
Bindings builder flexibility
Since
we now have about 20 libraries bound, the Wrapping builder script can
take a little while on slow systems to build all the bindings code. So
I've added the ability to specify which APILookup files to action.
eg. to build LibSoup you can do.
sh buildit.sh APILookupGLib.txt APILookupGObject.txt APILookupSoup.txt
It
cant do the dependancy resolution yet, so you have to list all the
pre-requisite packages so it has access to all the required types when
building the library you need.
The struct parser is also a little more robust now, handling comments and lists of elements eg.
ushort x, y;
Minor Gtk Fixes
- G.Object.setProperty(String key, Any value) now works, and converts value into G.Values automatically.
- GtkTreePath[]
Gtk.TreeSelection.prototype.getSelectedRows(Gtk.TreeModel model) now
works - although I need to look at generic ways to generate array of
Objects from GList..
- new Gtk.TreeStore(Array coltypes) now
works (where coltypes is either an array of strings, or G.Types.) -
this works along with the other constructor methods - eg. varargs......
- Gtk.TreeStore.prototype.set(Gtk.TreeIter
row, Array values) now works to quickly set the values of a tree row,
rather than calling set(GtkTreeIter row, Number col, Mixed value)
- Gtk.Container.prototype.remove(Number item) and Gtk.Container.prototype.remove(Gtk.Widget
widget) are now working - I need to change this slightly, so you can
remove all by sending '0' as the item, and waiting until it returns
false...
- Most of the GtkEvent Structures are now exported, and all the properties are available as getters.
- new
GdkColor(Number color) is based on 0xRRGGBB hexidecimal values, rather
than longintegers.. (you can use the long version to do more precise
colours: new GdkColor(Number red, Number green , Number blue);
- new
Gdk.Pixbuf(Array xpmdata) is now supported so converting xpm data for
use as icons is very simple (just replace "const char**" with "var")
ExtJs loading
One
of the goals is to make the engine compatible with existing code out
there, a nice test of this was extjs, which it can now load correctly
(with a few lines of javascript prefixing the loading). I've not
actually tested any of the functionality yet, as XmlHttpRequest needs
building from the libsoup bindings.
jLeds port underway..
What's
a language without an editor (or an email client - if you know the old
joke about every application eventually evolves until it can read
email.).. So partly to test the bindings I've started looking at
porting Leds to gtkjs - the code is in tests/jLeds, and gives a good
example of some of the new Javascript2 features, along with the gtk
bindings.
Try the newsgroup if you need support.
news://news.digitalmars.com/DMDScript